/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package processor;

import entity.Complaint;
import entity.Solution;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author maynoigi
 */
@Stateless
public class SolutionFacade extends AbstractFacade<Solution> {
    @PersistenceContext(unitName = "ManTechHelpdesk-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public SolutionFacade() {
        super(Solution.class);
    }
    
    public List<Solution> getSolutionByComplaintsID(Complaint complaint) {
        return (List<Solution>) em.createQuery("SELECT s FROM Solution s WHERE s.complaintID = :complaint").setParameter("complaint", complaint).getResultList();
    }

    public void createSolution(Solution solution) {
        create(solution);
    }

    public void deleteSolution(Solution solutionID) {

        em.remove((Solution) em.createNamedQuery("Solution.findBySolutionID").setParameter("solutionID", solutionID.getSolutionID()).getSingleResult());
    }
}
